package com.lee.dutylower.db.greenEntity;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToOne;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.DaoException;
import com.lee.dutylower.db.greendao.DaoSession;
import com.lee.dutylower.db.greendao.SentryDao;
import com.lee.dutylower.db.greendao.SoldierDao;
import com.lee.dutylower.db.greendao.DutySoldierRecordDao;

/**
 * Created by lijie on 2017/8/19.
 */

@Entity
public class DutySoldierRecord {

    @Id(autoincrement = true)
    private Long id;

    @Property
    private Long soldierID;

    @ToOne(joinProperty = "soldierID")
    private Soldier soldier;

    @Property
    private Long sentryID;

    @ToOne(joinProperty = "sentryID")
    private Sentry sentry;

    @Property
    private Integer counts;

    @Property
    private Integer daofweek;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    @Generated(hash = 701040371)
    private transient DutySoldierRecordDao myDao;

    @Generated(hash = 461865959)
    public DutySoldierRecord(Long id, Long soldierID, Long sentryID, Integer counts,
            Integer daofweek) {
        this.id = id;
        this.soldierID = soldierID;
        this.sentryID = sentryID;
        this.counts = counts;
        this.daofweek = daofweek;
    }

    @Generated(hash = 391790831)
    public DutySoldierRecord() {
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getSoldierID() {
        return this.soldierID;
    }

    public void setSoldierID(Long soldierID) {
        this.soldierID = soldierID;
    }

    public Long getSentryID() {
        return this.sentryID;
    }

    public void setSentryID(Long sentryID) {
        this.sentryID = sentryID;
    }

    public Integer getCounts() {
        return this.counts;
    }

    public void setCounts(Integer counts) {
        this.counts = counts;
    }

    @Generated(hash = 718234182)
    private transient Long soldier__resolvedKey;

    /** To-one relationship, resolved on first access. */
    @Generated(hash = 1752725337)
    public Soldier getSoldier() {
        Long __key = this.soldierID;
        if (soldier__resolvedKey == null || !soldier__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            SoldierDao targetDao = daoSession.getSoldierDao();
            Soldier soldierNew = targetDao.load(__key);
            synchronized (this) {
                soldier = soldierNew;
                soldier__resolvedKey = __key;
            }
        }
        return soldier;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1808852650)
    public void setSoldier(Soldier soldier) {
        synchronized (this) {
            this.soldier = soldier;
            soldierID = soldier == null ? null : soldier.getSID();
            soldier__resolvedKey = soldierID;
        }
    }

    @Generated(hash = 36734472)
    private transient Long sentry__resolvedKey;

    /** To-one relationship, resolved on first access. */
    @Generated(hash = 288920200)
    public Sentry getSentry() {
        Long __key = this.sentryID;
        if (sentry__resolvedKey == null || !sentry__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            SentryDao targetDao = daoSession.getSentryDao();
            Sentry sentryNew = targetDao.load(__key);
            synchronized (this) {
                sentry = sentryNew;
                sentry__resolvedKey = __key;
            }
        }
        return sentry;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 2061760017)
    public void setSentry(Sentry sentry) {
        synchronized (this) {
            this.sentry = sentry;
            sentryID = sentry == null ? null : sentry.getSentry_id();
            sentry__resolvedKey = sentryID;
        }
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1274015363)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getDutySoldierRecordDao() : null;
    }

    public Integer getDaofweek() {
        return this.daofweek;
    }

    public void setDaofweek(Integer daofweek) {
        this.daofweek = daofweek;
    }
}
